function [Z,Tris,Points] = heval(dofs,V,T,x,d,triangulars,d_plot)
%function [Z,Tris,Points] = heval(dofs,V,T,posT,x,d,triangulars,d_plot)
% this is the version for single degrees.
posT = size(T,1);
m = (d_plot+1)*(d_plot+2)/2;
[I,J,K] = indices(d_plot);
cell_per_tri = size(triangulars,1);
mat = vdm22(d, d_plot);
Tris = zeros(cell_per_tri*posT,3);
Points = zeros(m*posT,2);
Z = zeros(m*posT,1);
for tri = 1:posT
    Points((tri-1)*m+1:tri*m,:) = (I*V(T(tri,1),:)+J*V(T(tri,2),:)+K*V(T(tri,3),:))/d_plot;
    Z((tri-1)*m+1:tri*m) = mat * x(dofs(:,tri));
    Tris((tri-1)*cell_per_tri+1:tri*cell_per_tri,:) = triangulars + (tri-1)*m;
end
